<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<form:form commandName="coordinate" cssClass="form-horizontal" role="form">
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="problemName">问题名称</label>
		<div class="col-sm-4">
			<input type="text" name="problemName" id="problemName" placeholder="项目名" value="${coordinate.problemName}"
				   class="form-control"/>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="industryName">指标名称</label>
		<div class="col-sm-4">
			<input type="text" name="industryName" id="industryName" placeholder="指标名称"
				   value="${coordinate.industryName}"
				   class="form-control" readonly/>
		</div>
		<label class="col-sm-2 control-label no-padding-right" for="industryDate">指标时间</label>
		<div class="col-sm-4">
			<input type="text" name="industryDate" id="industryDate" placeholder="指标时间"
				   value="${coordinate.industryDate}"
				   class="form-control" readonly/>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="baseInfo">基本情况</label>
		<div class="col-sm-10">
            <textarea rows="2" id="baseInfo" name="baseInfo" placeholder="基本情况"
					  class="form-control ">${coordinate.baseInfo}</textarea>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="helpInfo">需协调事项</label>
		<div class="col-sm-10">
            <textarea id="helpInfo" name="helpInfo" rows="2" placeholder="需协调事项"
					  class="form-control ">${coordinate.helpInfo}</textarea>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="groupCode_check">督查组</label>
		<div class="col-sm-4">
			<select name="groupCode" id="groupCode_check"
					class="form-control <%--departments--%>" <%--multiple="multiple"--%> required>
				<option value="">--请选择--</option>
				<c:forEach items="${supervisionList }" var="supervisionList">
					<option value="${supervisionList.sysId}">${supervisionList.deptName}</option>
				</c:forEach>
			</select>
		</div>
		<label class="col-sm-2 control-label no-padding-right" for="deptId_check">责任单位</label>
		<div class="col-sm-4">
			<select name="deptId" id="deptId_check" class="form-control " required>
				<option value="">--请选择--</option>
				<c:forEach items="${resDepts }" var="resDepts">
					<option value="${resDepts.sysId}">${resDepts.deptName}</option>
				</c:forEach>
			</select>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="inspectors_check">督查组成员</label>
		<div class="col-sm-4">
			<input type="text" name="inspectors" id="inspectors_check" class="form-control" readonly required/>
		</div>
		<label class="col-sm-2 control-label no-padding-right" for="resUser_check">责任人</label>
		<div class="col-sm-4">
			<input type="text" name="resUser" id="resUser_check" class="form-control" readonly required/>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="phones_check">督查成员手机号</label>
		<div class="col-sm-4">
			<input type="text" name="phones" id="phones_check" class="form-control" readonly required/>
		</div>
		<label class="col-sm-2 control-label no-padding-right" for="resPhone_check">责任人手机号</label>
		<div class="col-sm-4">
			<input type="text" name="resPhone" id="resPhone_check" class="form-control" readonly required/>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="userName">上报人</label>
		<div class="col-sm-4">
			<input type="text" name="userName" id="userName" class="form-control" value="${coordinate.userName}"
				   readonly/>
		</div>
		<label class="col-sm-2 control-label no-padding-right" for="source">来源</label>
		<div class="col-sm-4">
			<input type="text" name="source" id="source" class="form-control" value="${coordinate.source}" required/>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="startDate">计划开始时间</label>
		<div class="col-sm-4">
			<input id="startDate"  type="text" name="planStartDate" class="form-control date-upd date-picker" required />
		</div>
		<label class="col-sm-2 control-label no-padding-right" for="endDate">计划结束时间</label>
		<div class="col-sm-4">
			<input id="endDate"  type="text" name="planEndDate" class="form-control date-upd date-picker" required />
		</div>

	</div>

	<input type="text" name="userId" id="userId_check" hidden />
	<input type="text" id="sysId" value="${coordinate.sysId}" hidden>
	<input type="text" name="industryId" value="${coordinate.industryId}" hidden>
	<form:hidden path="sysId"/>
	<%--<form:hidden path="maxVal"/>
    <form:hidden path="minVal"/> --%>
</form:form>
<script>

    $(function () {

        //责任单位
        var deptIdSelected = '${coordinate.deptId}';
        //jq选中select
        $("#deptId_check option[value = '" + deptIdSelected + "']").attr("selected", true);
        console.log(deptIdSelected)
        if (deptIdSelected != null) {
            var deptId = $("#deptId_check").val();
            $.ajax({
                url: "/jobmanages/queryResUserByDeptId",
                type: "GET",
                dataType: "json", //返回数据形式为json
                contentType: 'application/json;charset=UTF-8',
                async: true,
                data: {"deptId": deptId},
                success: function (res) {
                    if (res != null) {
                        $("#resUser_check").val(res.name);
                        $("#resPhone_check").val(res.mobile);
                        $("#userId_check").val(res.sysId);
                    }
                }
            });
        }

        $("#deptId_check").change(function () {
            var deptId = $("#deptId_check").val();
            $.ajax({
                url: "/jobmanages/queryResUserByDeptId",
                type: "GET",
                dataType: "json", //返回数据形式为json
                contentType: 'application/json;charset=UTF-8',
                async: true,
                data: {"deptId": deptId},
                success: function (res) {
                    if (res != null) {
                        $("#resUser_check").val(res.name);
                        $("#resPhone_check").val(res.mobile);
                    }
                }
            });
        });

        $("#groupCode_check").change(function () {
            var groupCode = $("#groupCode_check").val();
            $.ajax({
                url: "/jobmanages/querySupervisionUserByDeptId",
                type: "GET",
                dataType: "json", //返回数据形式为json
                contentType: 'application/json;charset=UTF-8',
                async: true,
                data: {"deptId": groupCode},
                success: function (res) {
                    if (res != null) {
                        $("#inspectors_check").val(res.name);
                        $("#phones_check").val(res.mobile);
                    }
                }
            });
        });

        //督查组
        var groupCodeSelected = '${coordinate.groupCode}';
        //jq选中select
        $("#groupCode_check option[value = '" + groupCodeSelected + "']").attr("selected", true);
        console.log(groupCodeSelected)
        if (groupCodeSelected != null) {
            var groupCode = $("#groupCode_check").val();
            $.ajax({
                url: "/jobmanages/querySupervisionUserByDeptId",
                type: "GET",
                dataType: "json", //返回数据形式为json
                contentType: 'application/json;charset=UTF-8',
                async: true,
                data: {"deptId": groupCode},
                success: function (res) {
                    if (res != null) {
                        $("#inspectors_check").val(res.name);
                        $("#phones_check").val(res.mobile);
                    }
                }
            });
        }


        $(".date-picker").datepicker({
            inline: true,
            format: "yyyymmdd",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        }).next().on(ace.click_event, function () {
            $(this).prev().focus();
        });

    })

</script>
